<%@ include file="connect.jsp" %>
<html>
<head>
    <link href="style.css" rel="stylesheet"/>
    <%
        String paragraf = request.getParameter("para");
        String learn = request.getParameter("learn");
        String id = request.getParameter("id");
        ResultSet rs = stat.executeQuery("select * from DetailLearn where DetailLearnid='" + id + "'");
        String words = "";
        String definition = "";
        String images = "";
        String example = "";
        String partOfSpeech = "";
        String wordstem = "";
        while (rs.next()) {
            words = rs.getString("words");
            definition = rs.getString("definition");
            images = rs.getString("images");
            example = rs.getString("example");
            partOfSpeech = rs.getString("partofspeech");
            wordstem = rs.getString("wordstem");
        }
    %>
    <script type="text/javascript" language="javascript">
        function validasi() {
            var kata = document.getElementById("word").value;
            var arti = document.getElementById("arti").value;
            var jenis = document.getElementById("tipeword").value;
            var cth = document.getElementById("contoh").value;
            var paragraf = document.getElementById("paragraf").value;
            var wordstem = document.getElementById("wordstem").value;
            if (kata == null || kata == "") {
                alert('Please insert the word');
                return false;
            }
            else if (arti == null || arti == "") {
                alert('Please insert the word');
                return false;
            }
            else if (jenis == null || arti == "") {
                alert('Please insert the part of speech');
                return false;
            }
            else if (cth == null || cth == "") {
                alert('Please insert the example');
                return false;
            }
            else if (wordstem == null || wordstem == "") {
                alert('Please insert the wordstem');
                return false;
            }
            else {
                return true;
            }
        }

    </script>
</head>
<body>
<div id="popup-header">
    <h2>Edit Word's Detail</h2>
</div>
<form method="post" action="doUpdateWord.jsp" onsubmit="return validasi()">
    <input type="hidden" name="learn" id="learn" value="<%=learn%>">
    <input type="hidden" name="id" id="id" value="<%=id%>">
    <table id="word1">

        <tr>
            <td>Word</td>
            <td>:</td>
            <td><input type="text" name="word" id="word" value="<%=words%>"></td>
        </tr>
        <tr>
            <td>Definition</td>
            <td>:</td>
            <td><textarea name="arti" id="arti"><%=definition%>
            </textarea></td>

        </tr>
        <tr>
            <td>Image</td>
            <td>:</td>
            <td><input type="text" name="image" id="image" value="<%=images%>"></td>
        </tr>
        <tr>
            <td>Part Of Speech</td>
            <td>:</td>
            <td><input type="text" name="tipeword" id="tipeword" value="<%=partOfSpeech%>"></td>
        </tr>
        <tr>
            <td>Word Stem</td>
            <td>:</td>
            <td><input type="text" name="wordstem" id="wordstem" value="<%=wordstem%>"></td>
        </tr>
        <tr>
            <td>Example</td>
            <td>:</td>
            <td><textarea name="contoh" id="contoh"><%=example%>
            </textarea></td>
        </tr>
        <tr id="warning">
            <td>

                <%
                    String respon = request.getParameter("respon");

                    if (respon != null) {

                        out.print(respon + " "); //ga tau nih gmn ya mau masukkin namanya, apa delete berdasarkan nama ??
                    } %>
            </td>
        </tr>
        <tr align="right">
            <td colspan="3">
                <div class="btn-fld">

                    <button type="submit">Save</button>

                </div>
            </td>
        </tr>


    </table>
</form>
</td>
</tr>

</table>
</body>
</html>